import 'package:flutter/material.dart';

class MineView extends StatefulWidget {
  const MineView({super.key});

  @override
  State<MineView> createState() => _MineViewState();
}

class _MineViewState extends State<MineView> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFFE3F2FD), // 浅蓝色背景
      appBar: AppBar(
        centerTitle: true,
        title: const Text('我的', style: TextStyle(color: Colors.black)),
        backgroundColor: const Color(0xFFE3F2FD),
        elevation: 0,
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // 用户信息区域
          Container(
            padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 25),
            child: Row(
              children: [
                // 用户头像
                const CircleAvatar(
                  radius: 40,
                  backgroundImage:
                      AssetImage('assets/images/avatar_1.jpg'), // 使用项目中的头像资源
                ),
                const SizedBox(width: 15),
                // 用户名和完善信息按钮
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const Text(
                        '用户名',
                        style: TextStyle(
                          fontSize: 18,
                          fontWeight: FontWeight.bold,
                          color: Colors.black,
                        ),
                      ),
                      const SizedBox(height: 5),
                      TextButton(
                        onPressed: () {
                          // 完善信息按钮点击事件
                        },
                        style: TextButton.styleFrom(
                          padding: EdgeInsets.zero,
                          minimumSize: Size.zero,
                        ),
                        child: const Text(
                          '完善信息 >',
                          style: TextStyle(
                            fontSize: 14,
                            color: Colors.black54,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          // 功能列表区域
          Container(
            margin: const EdgeInsets.symmetric(horizontal: 15),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(8),
              color: Colors.white,
            ),
            child: Column(
              children: [
                // 我的房屋
                _buildMenuItem(
                  iconPath: 'assets/images/house_profile_icon@2x.png',
                  title: '我的房屋',
                  onTap: () {
                    // 我的房屋点击事件
                  },
                ),
                Divider(height: 1, color: Colors.grey[200]),
                // 我的报修
                _buildMenuItem(
                  iconPath: 'assets/images/repair_profile_icon@2x.png',
                  title: '我的报修',
                  onTap: () {
                    // 我的报修点击事件
                  },
                ),
                Divider(height: 1, color: Colors.grey[200]),
                // 访客记录
                _buildMenuItem(
                  iconPath: 'assets/images/visitor_profile_icon@2x.png',
                  title: '访客记录',
                  onTap: () {
                    // 访客记录点击事件
                  },
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  // 构建菜单项的方法
  Widget _buildMenuItem({
    required String iconPath,
    required String title,
    required VoidCallback onTap,
  }) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
        child: Row(
          children: [
            Image.asset(
              iconPath,
              width: 24,
              height: 24,
            ),
            const SizedBox(width: 10),
            Text(
              title,
              style: const TextStyle(
                fontSize: 16,
                color: Colors.black,
              ),
            ),
            const Spacer(),
            Icon(
              Icons.arrow_forward_ios,
              size: 16,
              color: Colors.grey[400],
            ),
          ],
        ),
      ),
    );
  }
}
